<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .menu{
            width: 250px;
            height: 200px;
            background-color: aqua;
            position: absolute;
            top: 0;
            bottom: 0;
            right: 0;
            left: 0;
            margin: auto;
            /* 隐藏 */
            display: none;
        }
        th,td{
            width: 200px;
            height: 40px;
            border: 1px solid black;
        }
    </style>
</head>
<body>
    <button onclick="show()">添加</button>
    <!-- 小菜单 -->
    <div class="menu">
        <p class="yhm">用户名:<input type="text"></p>
        <p class="nl">年龄:<input type="text"></p>
        <button onclick="add()">确定</button><button>取消</button>
    </div>
    <table>
        <thead>
            <tr>
                <th>用户名</th>
                <th>年龄</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            
        </tbody>
    </table>
</body>
</html>
<script>
    var menu=document.querySelector('.menu')
    var yhm=document.querySelector('.yhm')
    var nl=document.querySelector('nl')
    var tbody=document.querySelector('tbody')
    function show(){
        menu.style.display='block'
    }
    function add(){
        //创建
        var tr=document.createElement('tr')
        //赋值
        tr.innerHTML=`
            <td>${yhm.value}</td>
            <td>${nl.value}</td>
            <td><button>删除</button></td>
        `;
        //添加
        tbody.appendChild(tr)
    }
</script>